package reflect;

import java.lang.reflect.Method;

/**
 * 调用有参方法
 */
public class ReflectDemo6 {
    public static void main(String[] args)throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();

        Method method = cls.getDeclaredMethod("say",String.class);//say(String)
        method.invoke(obj,"你好");//obj.say("你好");

        Method method2 = cls.getDeclaredMethod("say",String.class,int.class);
        method2.invoke(obj,"嘿嘿",5);



    }
}




